<?php

	#doc
	#	classname:	qflowerController
	#	scope:		PUBLIC
	#
	#/doc
	
	class QflowerController extends Controller
	{
		#	internal variables
		public $layout = "admin";
		public $img;
		#	Constructor
	
		public function filters()
		{
			return array(
				'accessControl',
			);
		}

		public function accessRules()
		{
		return array(


		array('allow',
			'actions'=>array('Add','List','Save','Del','Order ','View_zak ','del_zak'),
			'roles'=>array('admin')

			),
			array('deny',
			'actions'=>array('Add','List','Save','Del','Order ','View_zak ','del_zak'),
			'users'=>array('*')

			),


		);
	 }
			public function actionList ()
			{
				$flower=flower::model()->findAll();
				$this->render('application.views.qflower.list', array("flower"=>$flower));
			}
			public function actionAdd ()
			{
				$this->render('application.views.qflower.addflower');
			}
		public function actionSave ()
		{
			if((isset($_POST['title']))&&(isset($_POST['text'])))
			{
				$flower = new flower();
				$flower->name=$_POST['title'];
					$flower->text=$_POST['text'];
						
						 $img = CUploadedFile::getInstance($flower,'img');
								$upload = Yii::getPathOfAlias('open29').Yii::app()->controller->module->uploadPath;  


								   if($img != null)
									{      
									 $img->saveAs("images/flower/".$img);   
									}
									$flower->image=$img;
									
							if($flower->save())
								{
									$this->redirect('/adminka/qflower/list');
								}
				
			}
		}
		
		
		public function actionDel()
		{
			$id_flower=$_GET['id'];
			

			flower::model()->deleteAll("id_flower=:id_flower",array("id_flower"=>$id_flower));			

			$this->redirect('/adminka/qflower/list');
		}
		
		
		public function actionOrder ()
		{
			$flower=flower_zak::model()->findAll();
				$this->render('application.views.qflower.list_zak', array("flower"=>$flower));
		}
		
		public function actionView_zak ()
		{
		$id_zak=$_GET['id'];
			$flower=flower_zak::model()->findAll("id_zak=:id_zak",array(":id_zak"=>$id_zak));
				$this->render('application.views.qflower.view_zak', array("flower"=>$flower));
		}
		
		public function actiondel_zak ()
		{
			$id_zak=$_GET['id'];
			$flower=flower_zak::model()->deleteAll("id_zak=:id_zak",array(":id_zak"=>$id_zak));
			$this->redirect('/adminka/qflower/order');
		}
	
	}
	###

?>